package com.xxl.job.executor.sample.frameless.test.singleton;

import java.util.Scanner;

public class Exam {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        //输入购买苹果数量
        int n = in.nextInt();
        boolean flag = false;
        int total = 0;
        int k = n / 8;
        for (int i = k; i >= 0; i--) {
            if ((n - 8 * i) % 6 ==0) {
                flag = true;
                total = i + (n - 8 * i) / 6;
                break;
            }
        }
        if (!flag) {
            System.out.println(-1);
        }else {
            System.out.println(total);
        }
    }
}
